package share

import (
	"oc_saas/model/admin"
	"oc_saas/model/base"
)

// 角色表
type Role struct {
	base.IDColumn
	base.SortColumn
	PID       uint          `json:"pid" gorm:"comment:父ID;uniqueIndex:role_id_tag;"`
	Name      string        `json:"name" gorm:"not null;type:varchar(10);size:10;comment:角色名称"`
	Tag       string        `json:"tag" gorm:"not null;uniqueIndex:role_id_tag;comment:角色标识(与父ID组合索引)"`
	Link      string        `json:"link" gorm:"column:link;not null;type:varchar(255);size:255;index;comment:父子元素链条(,a,b,c,)"`
	DbID      uint          `json:"db_id" gorm:"not null;comment:角色所在的数据库"`
	JWTExpire uint          `json:"jwt_expire" gorm:"column:jwt_expire;type:int(13);size:13;default:259200;comment:jwt过期时间(单位秒)(默认三天过期)"`
	Roles     []*Role       `json:"-" gorm:"foreignKey:PID;reference:ID;constraint:OnDelete:CASCADE"`
	Users     []*admin.User `json:"accounts" gorm:"foreignKey:RoleID;reference:ID;constraint:OnDelete:CASCADE;"`
}
